<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html  xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:p="http://primefaces.org/ui">
    <h:head>
    </h:head>
    <h:body>
        <ui:composition>
            <p:outputPanel>
                <p:dataTable id="tblGroups_Data" value="#{func_admin_group.listGroups}" var="group" rowKey="#{group.GROUP_ID}" rowIndexVar="indexv" style="border: 5px" selection="#{func_admin_group.group}" selectionMode="single">
                    <p:ajax event="rowSelect" listener="#{func_admin_group.onRowSelect()}" process="@this :form_main_admin:tblGroups_Data" partialSubmit="true" update=":form_main_admin:dialogGroup :form_main_admin:tblGroups_Data"/>
                    <f:facet name="header">  
                        <h:outputText value="Groups Management" style="font-size:15px"/>
                    </f:facet>
                    <p:column headerText="Index" style="width: 5%; font-size: 15px">
                        #{indexv + 1}
                    </p:column>
                    <p:column headerText="Group ID" style="text-align: center; font-size: 15px">
                        #{group.GROUP_ID}
                    </p:column>
                    <p:column headerText="Group Name" style="text-align: center; font-size: 15px">
                        #{group.GROUP_NAME}
                    </p:column>
                    <p:column headerText="Description" style="text-align: center; font-size: 15px">
                        #{group.DESCRIPTION}
                    </p:column>
                    <p:column headerText="Status" style="text-align: center; font-size: 15px">
                        <h:outputText value="#{func_admin_group.activeState.get(indexv)}"/>
                    </p:column>
                    <p:column headerText="Rights" style="text-align: center; font-size: 15px">
                        <p:selectCheckboxMenu value="#{func_admin_group.listRightsSelect}" label="Rights" style="text-align: center; font-size: 15px">  
                            <f:selectItems value="#{func_admin_group.selectedRight}"></f:selectItems>
                        </p:selectCheckboxMenu> 
                    </p:column>
                    <f:facet name="footer">  
                        <p:commandButton id="add-id" value="Add" style="width: 60px; height: 30px; text-align: center; font-size: 12px" oncomplete="GroupDialog.show()" actionListener="#{func_admin_group.handAdd()}" update=":form_main_admin:dialogGroup :form_main_admin:tblGroups_Data" process="@this :form_main_admin:tblGroups_Data" disabled="#{not func_admin_group.ctrAdd}"></p:commandButton>
                        <p:commandButton id="edit-id" value="Edit" style="width: 60px; height: 30px; text-align: center; font-size: 12px" actionListener="#{func_admin_group.handEdit()}" oncomplete="GroupDialog.show()" update=":form_main_admin:tblGroups_Data :form_main_admin:dialogGroup" process="@this :form_main_admin:tblGroups_Data" disabled="#{not func_admin_group.ctrEdit}"></p:commandButton>
                        <p:commandButton id="del-id" value="Delete" style="width: 70px; height: 30px; text-align: center; font-size: 12px" actionListener="#{func_admin_group.handDelete()}" update=":form_main_admin:tblGroups_Data" process="@this :form_main_admin:tblGroups_Data" onclick="if (!confirm('Are you sure to delete this group ?')) return false" disabled="#{not func_admin_group.ctrDel}"></p:commandButton>
                    </f:facet> 
                </p:dataTable>
                <p:dialog id="dialogGroup" header="#{func_admin_group.dialogState}" widgetVar="GroupDialog" resizable="false" style="font-size: 15px" 
                          width="250" showEffect="clip" hideEffect="fold">  

                    <h:panelGrid id="display" columns="2" cellpadding="4">  
                        <h:outputText value="Group ID:" />  
                        <h:inputText value="#{func_admin_group.group.GROUP_ID}" disabled="true" style="width: 110px" required="true"/>  

                        <h:outputText value="Group Name:" />  
                        <h:inputText value="#{func_admin_group.group.GROUP_NAME}" style="width: 110px" required="true"/>  

                        <h:outputText value="Description" />  
                        <h:inputText value="#{func_admin_group.group.DESCRIPTION}" style="width: 110px" required="true"/>   

                        <h:outputText value="Status:" />  
                        <p:selectOneMenu value="#{func_admin_group.group.STATUS}" style="width: 110px">  
                            <f:selectItem itemLabel="Disable" itemValue="0"/>  
                            <f:selectItem itemLabel="Enable" itemValue="1"/>  
                        </p:selectOneMenu>
                        <h:outputText value="Rights" />  
                        <p:selectCheckboxMenu value="#{func_admin_group.listRights}" label="Rights">  
                            <f:selectItems value="#{func_admin_group.selectedRight}" />  
                        </p:selectCheckboxMenu>
                        <f:facet name="footer">
                            <p:commandButton value="OK" style="font-size: 12px; width: 50px; height: 25px" actionListener="#{func_admin_group.handOk()}" oncomplete="GroupDialog.hide()" update=":form_main_admin:tblGroups_Data :form_main_admin:dialogGroup" process="@this :form_main_admin:dialogGroup"></p:commandButton>
                            <p:commandButton value="Cancel" style="font-size: 12px; width: 70px; height: 25px" oncomplete="GroupDialog.hide()" update=":form_main_admin:tblGroups_Data" process="@parent" actionListener="#{func_admin_group.cancel()}"></p:commandButton>
                        </f:facet>
                    </h:panelGrid>  
                </p:dialog>  
            </p:outputPanel>
        </ui:composition>
    </h:body>
</html>
